package com.example.demo_one.kotlin

fun main(){

    // 1. 基本的遍历
    for (i in 1 .. 10){
        print(i)
    }

    println("-----------------")
    // 2. 遍历 1~9 用until
    for (i in 1 until 11){
        print(i)
    }
    println("-----------------")
    // 3. 遍历 1、3、5、7、9
    for (i in 1..10 step 2){
        print(i)
    }
    println("-----------------")
    // 4. 降序遍历
    for (i in 10 downTo 1){
        print(i)
    }
    println("-----------------")
    val myList = listOf(1,2,3,4,5,6,7,8,9,10)
    for (i in myList){
        print(i)
    }
    myList.forEach { println(it) }
}


